// CadToolPoint.cpp
//
#include "CadToolPoint.h"

#include "CadEngine.h"

#include "OpenGL/OpenGL.h"
#include "OpenGL/Renderer.h"

//-------------------------------------------------------------------------------------------------
CadToolPoint::CadToolPoint()
: CadTool("Point",1)
{
	_creationColor = OpenGL::Color::yellow();
}

//-------------------------------------------------------------------------------------------------
CadToolPoint::~CadToolPoint()
{}

//-------------------------------------------------------------------------------------------------
void CadToolPoint::execute()
{
	CadEngine::Command c;
	c.command   = CadEngine::Create;
	c.primitive = CadEngine::Point;
	c.color     = _creationColor;
	c.points.push_back( _points[0] );
	c.attributes += _objectAttributes;

	_manager->issueCommand(c);
}

// --------------------------------------------------------------------------------------------
void CadToolPoint::setCreationColor( const OpenGL::Color &c ) { _creationColor = c; }

// --------------------------------------------------------------------------------------------
OpenGL::Color CadToolPoint::creationColor() const { return _creationColor; }

// --------------------------------------------------------------------------------------------
void CadToolPoint::draw( OpenGL::Renderer *r )
{
	if(_nPoints == 0)
		return;

	glPointSize(9.0);
	glColor3ub(0x00, 0x00, 0x00);
	glBegin(GL_POINTS);
		r->glVertex3( _points[0] );
	glEnd();

	glPointSize(7.0);
	glColor4fv( _manager->settings().previewColor().rgba() );
	glBegin(GL_POINTS);
		r->glVertex3( _points[0] );
	glEnd();
}